<!DOCTYPE html>
<html lang="en" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta charset="UTF-8">
    <title>词条管理页面</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/custom.form.css">
    <link rel="stylesheet" href="/css/index.css">

</head>
<body>




<div id="searchParam" shiro:hasPermission="sys:entry:list">
    <div class="layui-form-item">
        <div class="layui-input-inline">
            <input type="text" id="pinyin" name="pinyin" class="layui-input" autocomplete="off" placeholder="文字或拼音">
        </div>

        <div class="layui-input-inline">
            <input type="text" id="strokes" name="strokes" class="layui-input" autocomplete="off" placeholder="输入笔画">
        </div>
<!--        <div class="layui-input-inline layui-form">-->
<!--            <select id="papertagList"  name="papertagList" class="select">-->

<!--            </select>-->
<!--        </div>-->
        <div class="layui-input-inline layui-form" >
            <select id="hsk"  name="hsk" class="select">

            </select>
        </div>

        <div class="layui-input-inline layui-form" >
            <select id="languageList"  name="languageList" class="select">

            </select>
        </div>

        <div class="layui-input-inline layui-form">
            <select id="convType"  name="convType" class="select">
                <option value="1">汉外 </option>
                <option value="2">外汉</option>

            </select>
        </div>



        <!--        <div class="layui-input-inline">-->
        <!--            <select id="convType"  name="convType" class="select">-->

        <!--            </select>-->
        <!--        </div>-->

        <div class="layui-input-inline ">
            <button class="layui-btn" id="search">
                <span class="layui-icon layui-icon-search"></span>查询
            </button>
        </div>
    </div>
</div>
<table class="layui-hide" id="subjectObject_table" lay-filter="subjectObject_table" lay-skin="line"></table>
<div id="laypage" class="$('.layui-laypage-btn').click();"></div>
<!--增加修改模块--->
<div id="edit-user-info" style="display:none;">
    <form class="layui-form" action="" style="margin-top: 10px;margin-left: 10px;margin-right: 10px;" lay-filter="languageEditFilter" id="languageEditFilter" autocomplete="off">
        <div class="layui-card-body">
            <div class="main-div">
                <input name="id" hidden/>
                <input name="deptId" hidden/>

                <div class="layui-form-item">

                    <div class="layui-inline">
                        <div class="layui-form-label">词头</div>
                        <div class="layui-input-block">
                            <input type="text" name="prefix" placeholder="请输入词头"  class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-form-label">拼音</div>
                        <div class="layui-input-block">
                            <input type="textarea" name="pinyin" placeholder="请填写拼音"  class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-form-label">HSK等级</div>
                        <div class="layui-input-block">
                            <select id="hsknew" name="hsk"></select>
                        </div>
                    </div>
                </div><br/>
                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 10px;">
                    <legend style="font-size: small">创建索引</legend>
                </fieldset>
                <div class="layui-form-item">

                    <div class="layui-inline">
                        <div class="layui-form-label">笔画</div>
                        <div class="layui-input-block">
                            <input type="text" name="strokes" id="strokes" placeholder="请输入笔画索引"  class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-form-label">拼音</div>
                        <div class="layui-input-block">
                            <input type="textarea" name="pinyinIndex" placeholder="请输入拼音索引"  class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-form-label">部首</div>
                        <div class="layui-input-block">
                            <input type="textarea" name="radicalIndex" placeholder="请输入部首索引"  class="layui-input">
                        </div>
                    </div>
                </div>
                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 10px;">
                    <legend style="font-size: small">词条种类/类型</legend>
                </fieldset>
                <div class="layui-form-item">
<!--                    <div class="layui-inline">-->
<!--                        <label class="layui-form-label">题目类型</label>-->
<!--                        <div class="layui-input-block">-->
<!--                            <select id="type" name="type" ></select>-->
<!--                        </div>-->
<!--                    </div>-->
                    <div class="layui-inline">
                        <div class="layui-form-label">语种</div>
                        <div class="layui-input-block">
                            <select id="language" name="language"></select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-form-label">类型</div>
                        <div class="layui-input-block">
                            <select  id="statusv" name="statusv">
                                <option  value="">请选择语种类型</option>
                                <option   value="1">汉外</option>
                                <option   value="2">外汉</option>
                            </select>
                        </div>
                    </div><br/><br/>
                    <div class="layui-inline">
                        <div class="layui-form-label">配图</div>
<!--                        <img class="layui-upload-img" id="subjectimg" name="subjectimg" src="" style="margin-left: 20px;width: 70px;height: 50px;" />-->
<!--                        <input type="textarea" name="imageUrl"  class="layui-input">
-->

                        <input type="text" name="imageLists" id="imageLists" value="" class="layui-input">
                        <div id="subjectimg" name="subjectimg"   lay-filter="deleteds">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button type="button"  class="layui-btn" id="peituUoload">上传</button>
                    </div>

                    <div class="layui-inline">
                        <div class="layui-form-label">笔顺动画</div>
                        <div class="layui-input-block">
<!--                            <input type="textarea" name="strokeOrder"  class="layui-input">-->
                            <input type="text" name="strokeOrder"  id="strokeOrder" class="layui-input">
                            <div id="subjectvideos" name="strokeOrder" >
                            </div>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button type="button"  class="layui-btn" id="videostoveUpload">上传</button>
                    </div><br/><br/>
                    <div class="layui-inline">
                        <div class="layui-form-label">视频</div>
                        <div class="layui-input-block">
<!--                            <input type="textarea" name="videoUrl"  class="layui-input">-->
                            <input type="text" name="videoLists"  id="videoLists" class="layui-input">
                            <div id="subjectvideo" name="subjectvideo" >
                            </div>
                        </div>

                    </div>
                    <div class="layui-inline">
                        <button type="button"  class="layui-btn" id="videoUpload">上传</button>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-form-label">录音</div>
                        <div class="layui-input-block">
<!--                            <input type="textarea" name="recording"  class="layui-input">-->
                            <input type="text" name="recording" id="recording" value="" class="layui-input">
                            <div id="subjectrecord" name="subjectrecord" >
                            </div>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button type="button"  class="layui-btn" id="recordUpload">上传</button>
                    </div>

                </div>
                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 10px;">
                    <legend style="font-size: small">实例</legend>
                </fieldset>
                <div class="layui-form-item">
<!--                    <div class="layui-inline">-->
<!--                        <div class="layui-form-label">词性</div>-->
<!--                        <div class="layui-input-block">-->
<!--                            <input type="text" name="part" id="part" placeholder="请输入词性，比如名词，动词" class="layui-input">-->
<!--                        </div>-->
<!--                    </div>-->
                    <div class="layui-inline">
                        <div class="layui-form-label">组词</div>
                        <div class="layui-input-block">
                            <input type="text" name="phrase" id="phrase" placeholder="请输入组词" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-form-label">释义</div>
                        <div class="layui-input-block">
                            <input type="text" name="interpretation" id="interpretation" placeholder="请输入释义" class="layui-input">
                        </div>
                    </div><br/><br/>
                    <div class="layui-inline">
                        <div class="layui-form-label">例句</div>
                        <div class="layui-input-block">
                            <input type="text" name="sentence" id="sentence" placeholder="请输入例句" style="width: 800px;height: 40px;" class="layui-input">
                        </div>
                    </div><br/>
                    <div class="layui-inline">
                        <div class="layui-form-label">拼音</div>
                        <div class="layui-input-block">
                            <input type="text" name="pinyin" id="pinyin" placeholder="请输入例句" style="width: 800px;height: 40px;" class="layui-input">
                        </div>
                    </div>
<!--                    <div class="layui-inline">-->
<!--                        <div class="layui-form-label">例句-外</div>-->
<!--                        <div class="layui-input-block">-->
<!--                            <input type="text" name="interpretationTranslate" id="interpretationTranslate" placeholder="请输入例句" style="width: 800px;height: 40px;" class="layui-input">-->
<!--                        </div>-->
<!--                    </div>-->
                </div>
                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 10px; ">
                    <legend style="font-size: small">设置近/反义词</legend>
                </fieldset>
                <div class="layui-form-item">

                    <div class="layui-inline">
                        <div class="layui-form-label">近义词</div>
                        <div class="layui-input-block">
                            <input type="text" name="similar" id="similar" placeholder="请输入近义词" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-form-label">反义词</div>
                        <div class="layui-input-block">
                            <input type="text" name="antonym" id="antonym" placeholder="请输入反义词" class="layui-input">
                        </div>
                    </div>
                </div>


            </div>
        </div>
        <div class="layui-form-item">
            <div style="text-align: center;">
                <button type="submit" class="layui-btn" lay-submit="" lay-filter="edit-language-submit">保存</button>
                <button class="layui-btn layui-btn-primary" id="btn_cancel">返回</button>
            </div>
        </div>
    </form>
</div>


<!--批量导入模块--->
<div id="batUpload-info" style="display:none;">
    <form class="layui-form" action="" style="margin-top: 10px;margin-left: 10px;margin-right: 10px;" lay-filter="batuploadEditFilter" id="batuploadEditFilter" autocomplete="off">
        <div class="layui-card-body">
            <div class="main-div">
                <input name="id" hidden/>
                <input name="deptId" hidden/>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">词条语种</label>
                        <div class="layui-input-block">
                            <select id="type" name="type" ></select>
                        </div>
                    </div>

                    <div class="layui-inline">
                        <div class="layui-form-label">语种类型</div>
                        <div class="layui-input-block">
                            <select  id="statusva" name="statusva">
                                <option  value="">请选择语种类型</option>
                                <option   value="1">汉外</option>
                                <option   value="2">外汉</option>
                            </select>
                        </div>
                    </div>


                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <button type="button" class="layui-btn " id="testList">选择多文件</button>
                        </div>
                        <div class="layui-inline">
                            <button type="button" class="layui-btn" id="testListAction">保存</button>
                        </div>
                    </div>

                    <div class="layui-upload">

                        <div class="layui-upload-list">
                            <table class="layui-table">
                                <thead>
                                <tr><th>文件名</th>
                                    <th>大小</th>
                                    <th>状态</th>
                                    <th>操作</th>
                                </tr></thead>
                                <tbody id="demoList"></tbody>
                            </table>
                        </div>

                    </div>
                </div>

        </div>
        </div>
    </form>










</body>
<script type="text/html" id="toolbar">
    <div class="layui-btn-group">
        <button type="button" class="layui-btn layui-btn-sm" lay-event="addNewStudy" shiro:hasPermission="sys:entry:add">
            <i class="layui-icon">&#xe608;</i> 新增
        </button>
    </div>
    <div class="layui-btn-group">
        <button type="button" class="layui-btn layui-btn-sm"  lay-event="batUpoload" shiro:hasPermission="sys:entry:upload">
            <i class="layui-icon">&#xe608;</i>批量导入
        </button>
    </div>
    <div class="layui-btn-group">
        <button type="button" class="layui-btn layui-btn-sm" lay-event="DeployCase" shiro:hasPermission="sys:entry:deploy">
            <i class="layui-icon">&#xe608;</i> 发布
        </button>
    </div>
    <div class="layui-btn-group">
        <button type="button" class="layui-btn layui-btn-sm" lay-event="cancleDeployCase" shiro:hasPermission="sys:entry:cancleDeploy">
            <i class="layui-icon">&#xe608;</i> 取消发布
        </button>
    </div>
    <div class="layui-btn-group">
        <button type="button" class="layui-btn layui-btn-sm" lay-event="shenheCase" shiro:hasPermission="sys:entry:shenhe">
            <i class="layui-icon">&#xe608;</i> 审核
        </button>
    </div>
    <div class="layui-btn-group">
        <button type="button" class="layui-btn layui-btn-sm" lay-event="cancleshenheCase" shiro:hasPermission="sys:entry:shenhe">
            <i class="layui-icon">&#xe608;</i> 取消审核
        </button>
    </div>
    <div class="layui-btn-group">
        <button type="button" class="layui-btn layui-btn-sm" lay-event="buffDelete" shiro:hasPermission="sys:entry:deleted">
            <i class="layui-icon">&#xe640;</i> 批量删除
        </button>
    </div>
</script>
<script type="text/html" id="tool">

    <a class="layui-btn layui-btn-xs" lay-event="edit" shiro:hasPermission="sys:entry:update">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="batdel" shiro:hasPermission="sys:entry:DELETED">删除</a>
</script>
<script type="text/javascript" src="/js/jquery-1.11.3.min.js"></script>
<script src="/layui/layui.all.js"></script>
<script src="/js/core.util.js"></script>
<script src="/js/index.js"></script>
<script type="text/javascript" src="/js/dictionaryupload.js"></script>
<script type="text/javascript" src="/js/upload/upload.js"></script>
<!---回显数据-->
<script type="text/javascript" src="/js/selectss.js"></script>
<script>
    let $ = jQuery = layui.jquery;
    let table = layui.table
        , laypage = layui.laypage
        , form = layui.form
        , layer = layui.layer
        , laydate = layui.laydate
        , tree = layui.tree;
    layui.use(['table', 'laypage', 'layer', 'laydate', 'tree'], function () {

        //搜索条件
        let searchParam = {
            param :null,
            type:null,
            language:null,
            convType :null,
            page : 1,
            language:1,
            pageSize:10
        };


        //查询按钮点击事件
        $("#search").click(function () {
            if($("#languageList").val()==""||$("#languageList").val()==null){

layer.alert("语种不能为空!");
return;
        }
            searchParam.param = $("#pinyin").val();
            searchParam.strokes = $("#strokes").val();
            searchParam.hsk = $("#hsk").val();
            searchParam.language = $("#languageList").val();
            searchParam.convType = $("#convType").val();
            searchParam.page = 1;
            searchParam.pageSize = 10;
            CoreUtil.sendAjax("/dEntry/selectEntryIsPage", searchParam, function (res) {
                laypageTable(res.data.totalRows, searchParam.page);
                if (res.data.records != null) {
                    loadTable(res.data.records);
                }
            }, "GET", false, function (res) {
                layer.msg(res.msg);
                let noAuthorityData = [];
                loadTable(noAuthorityData);
            });
        });

        $(document).ready(function(){
            //试题标签的下拉选择框languageList

            CoreUtil.sendAjax("/dSubjectType/selectSubjectTypeIsNotPage",  null, function(res) {
                // alert("res.data====="+res.data)
                console.log(res);
                $("#papertagList").append(new Option("试题标签", ""));
                $("#type").append(new Option("试题标签", ""));
                $.each(res.data, function (index, item) {
                    $('#papertagList').append(new Option(item.typeName, item.id));// 下拉菜单里添加元素
                    $('#type').append(new Option(item.typeName, item.id));// 下拉菜单里添加元素

                });
                layui.form.render("select");
            }, "GET", false, function (res) {
                layer.msg("抱歉！您暂无获取列表的权限");
            });

//学习等级下拉选择框
            CoreUtil.sendAjax("/dStudyLevel/selectStudyLevelIsNotPage",  null, function(res) {
                console.log(res);

                $("#hsk").append(new Option("请选择学习等级", ""));
                $.each(res.data, function (index, item) {
                    $('#hsk').append(new Option(item.levelName, item.id));// 下拉菜单里添加元素

                });
                layui.form.render("select");
            }, "GET", false, function (res) {
                layer.msg("抱歉！您暂无获取列表的权限");
            });

            //语种的下拉选择框languageList

            CoreUtil.sendAjax("/dLanguage/selectLanguageIsNotPage",  null, function(res) {
                console.log(res);
                $("#languageList").append(new Option("语种", ""));
                $("#language").append(new Option("语种", ""));
                $.each(res.data, function (index, item) {
                    $('#languageList').append(new Option(item.languageName, item.id));// 下拉菜单里添加元素
                    $('#language').append(new Option(item.languageName, item.id));// 下拉菜单里添加元素
                });
                layui.form.render("select");
            }, "GET", false, function (res) {
                layer.msg("抱歉！您暂无获取列表的权限");
            });

            //类型的下拉选择框convtype

            // CoreUtil.sendAjax("/dEntry/selectLanguageIsNotPage",  null, function(res) {
            //     console.log(res);
            //     $("#languageList").append(new Option("类型", ""));
            //     $.each(res.data, function (index, item) {
            //         $('#languageList').append(new Option(item.languageName, item.id));// 下拉菜单里添加元素
            //     });
            //     layui.form.render("select");
            // }, "GET", false, function (res) {
            //     layer.msg("抱歉！您暂无获取列表的权限");
            // });

            //分页获取列表信息接口
            CoreUtil.sendAjax("/dEntry/selectEntryIsPage",  searchParam, function(res) {
                console.log(res);
                laypageTable(res.data.total, searchParam.page);
                if (res.data.records != null) {
                    loadTable(res.data.records);
                }
            }, "GET", false, function (res) {
                layer.msg("抱歉！您暂无获取列表的权限");
                let noAuthorityData = [];
                loadTable(noAuthorityData);
            });
        });

        //分页条
        let laypageTable = function (count, currentPage) {
            laypage.render({
                elem: 'laypage'
                , count: count
                , limit: searchParam.pageSize
                , layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
                , curr: location.hash.replace('#!currentPage=', '') //获取起始页
                , hash: 'currentPage' //自定义hash值
                , limits: [10, 25, 50, 100, 300, 500, 2000]
                , jump: function (obj, first) {
                    if (!first) {
                        searchParam.page = obj.curr;
                        searchParam.pageSize = obj.limit;
                        CoreUtil.sendAjax("/dEntry/selectEntryIsPage", searchParam, function (res) {
                            if (res.data.records != null) {
                                loadTable(res.data.records);
                                laypageTable(res.data.total, searchParam.page);
                            }
                        }, "GET", false, function (res) {
                            layer.msg("抱歉！您暂无获取列表信息的权限");
                            let noAuthorityData = [];
                            loadTable(noAuthorityData);
                        });

                    }
                }
            });
        };

        //渲染table
        let loadTable = function (data) {
            table.render({
                elem: '#subjectObject_table'
                , cols: [
                    [ {type: 'checkbox', fixed: 'left'},
                        {type: 'id', fixed: 'left', title: 'ID', width: '5%', type: 'numbers'},
                        {field: 'prefix', title: '词头', width: '15%', event: 'prefix', style:'cursor: pointer;' },
                        {field: 'pinyin', title: '拼音', width: '10%', event: 'pinyin', style:'cursor: pointer;' },
                        {field: 'languageName', title: '语种', width: '10%', event: 'languageName', style:'cursor: pointer;'},
                        {field: 'convType', title: '类型', width: '5%', event: 'convType', style:'cursor: pointer;',templet:function(item){

                                if(item.convType==1){
                                    return "汉外"
                                }   if(item.convType==2){
                                    return "外汉"
                                }

                            }},
                        {field: 'strokes', title: '笔画', width: '5%', event: 'strokes', style:'cursor: pointer;'},
                        {field: 'pinyinIndex', title: '拼音索引', width: '10%', event: 'pinyinIndex', style:'cursor: pointer;'},
                        {field: 'radicalIndex', title: '部首', width: '5%', event: 'radicalIndex', style:'cursor: pointer;'},
                        {field: 'hsk', title: 'HSK等级', width: '10%', event: 'hsk', style:'cursor: pointer;'},
                        {field: 'releaseState', title: '发布情况', width: '10%', event: 'releaseState', style:'cursor: pointer;', templet:function(item){
                            if(item.releaseState==1){

                          return '  <a class="layui-btn layui-btn-xs">发布</a>'
                            } if(item.releaseState==2){

                                    return '  <a class="layui-btn layui-btn-xs">未发布</a>'
                                }
                                if(item.releaseState==0){

                                    return '  <a class="layui-btn layui-btn-xs">未发布</a>'
                                }

                            }},
                        {width: '12%', toolbar: "#tool", title: '操作'}
                    ]
                ]
                , data: data
                , loading: true
                , even: true
                , limit: data.length
                , toolbar: '#toolbar'
            });
        };
        //监听表格头部工具栏事件
        table.on('toolbar(subjectObject_table)', function (obj) {
            let data = obj.data;
            switch (obj.event) {
                case 'addNewStudy':
                    //重置表单数据
                    $("#languageEditFilter")[0].reset();
                    form.render();
                    //打开弹框
                    layer.open({
                        //layer提供了5种层类型。可传入的值有：0（信息框，默认）1（页面层）2（iframe层）3（加载层）4（tips层）
                        type: 1,
                        resize: false, //是否允许拉伸
                        maxmin: false, //最大最小化
                        title: "新增词条",
                        area: ['80%', '80%'],
                        content: $("#edit-user-info") //引用的弹出层的页面层的方式加载修改界面表单
                    });
                    //初始化部门树型
                    break;
                case 'batUpoload':
                    //重置表单数据
                    $("#batuploadEditFilter")[0].reset();
                    form.render();
                    //打开弹框
                    layer.open({
                        //layer提供了5种层类型。可传入的值有：0（信息框，默认）1（页面层）2（iframe层）3（加载层）4（tips层）
                        type: 1,
                        resize: false, //是否允许拉伸
                        maxmin: false, //最大最小化
                        title: "批量导入词条",
                        area: ['60%', '90%'],
                        content: $("#batUpload-info") //引用的弹出层的页面层的方式加载修改界面表单
                    });
                    //初始化部门树型
                    break;
                case 'batchDeleted':
                    let checkStatus = table.checkStatus(obj.config.id);
                    let data2 = checkStatus.data;
                    if (data2.length == 0) {
                        layer.msg("请选择要删除的用户");
                    } else {
                        let userIds = [];
                        $(data2).each(function (index, item) {
                            userIds.push(item.id);
                        });
                        tipDialog(userIds, "");
                    }
                    break;
                case 'buffDelete':
                    let checkStatuss = table.checkStatus(obj.config.id);
                    let data2s = checkStatuss.data;
                    if (data2s.length == 0) {
                        layer.msg("请选择要删除的用户");
                    } else {
                        let userIdss = [];
                        let languages="";
                        $(data2s).each(function (index, item) {
                            userIdss.push(item.id);
                            languages=item.language;
                        });
                        // alert(languages)
                        tipforbidDialog(userIdss, languages);
                    }
                    break;
                case 'DeployCase':
                    // let checkStatuss = table.checkStatus(obj.config.id);
                    let DeployCaseData = table.checkStatus(obj.config.id).data;
                    if (DeployCaseData.length == 0) {
                        layer.msg("请选择要发布的编号");
                    } else {
                        let userIdss = [];
                        var language="";
                        $(DeployCaseData).each(function (index, item) {
                            userIdss.push(item.id);
                            language=item.language;
                        });
                        // alert(languages)
                        DeployDialog(userIdss,language);
                    }
                    break;
                case 'cancleDeployCase':
                    // let checkStatuss = table.checkStatus(obj.config.id);
                    let cancleDeployCaseData = table.checkStatus(obj.config.id).data;
                    if (cancleDeployCaseData.length == 0) {
                        layer.msg("请选择要取消发布的编号");
                    } else {
                        let userIdss = [];
                        let language="";
                        $(cancleDeployCaseData).each(function (index, item) {
                            userIdss.push(item.id);
                            language=item.language;
                        });
                        // alert(languages)
                        cancleDeployDialog(userIdss,language);
                    }
                    break;
                case 'shenheCase':
                    // let checkStatuss = table.checkStatus(obj.config.id);
                    let shenheDeployCaseData = table.checkStatus(obj.config.id).data;
                    if (shenheDeployCaseData.length == 0) {
                        layer.msg("请选择要审核的编号");
                    } else {
                        let userIdss = [];
                        let language="";
                        $(shenheDeployCaseData).each(function (index, item) {
                            userIdss.push(item.id);
                            language=item.language;
                        });
                        // alert(languages)
                        shenheDeployDialog(userIdss,language);
                    }
                    break;
                case 'cancleshenheCase':
                    // let checkStatuss = table.checkStatus(obj.config.id);
                    let cancleshenheDeployCaseData = table.checkStatus(obj.config.id).data;
                    if (cancleshenheDeployCaseData.length == 0) {
                        layer.msg("请选择要审核的编号");
                    } else {
                        let userIdss = [];
                        let language="";
                        $(cancleshenheDeployCaseData).each(function (index, item) {
                            userIdss.push(item.id);
                            language=item.language;
                        });
                        // alert(languages)
                        cancleshenheDeployDialog(userIdss,language);
                    }
                    break;
                case 'LAYTABLE_TIPS':
                    layer.msg("这是工具栏右侧自定义的一个图标按钮");
                    break;
            }
        });
        //监听行工具事件
        table.on('tool(subjectObject_table)', function (obj) {
            let data = obj.data;
            switch (obj.event) {
                case 'batdel':
                    let userIds = [];
                    userIds.push(data.id);
                    sureDelete(userIds,data.language);//删除


                    break;
                case 'edit':
                    layer.open({
                        //layer提供了5种层类型。可传入的值有：0（信息框，默认）1（页面层）2（iframe层）3（加载层）4（tips层）
                        type: 1,
                        resize: false, //是否允许拉伸
                        maxmin: false, //最大最小化
                        title: "修改信息",
                        area: ['100%', '100%'],
                        content: $("#edit-user-info") //引用的弹出层的页面层的方式加载修改界面表单
                    });
                    //回显数据，填充表格
                    setFormValue(obj);
                    //初始化部门树型
                    initTree("");
                    break;
            }
        });

        //是否批量删除确认框
        let tipforbidDialog = function (userIds, languages) {

            // alert(JSON.stringify(params))
            layer.open({
                content: '确定要删除吗?',
                yes: function (index, layero) {
                    layer.close(index); //如果设定了yes回调，需进行手工关闭
                    CoreUtil.sendAjax("/dEntry/deleteEntry?language="+languages, JSON.stringify(userIds), function (res) {
                        layer.msg(res.msg);
                        $(".layui-laypage-btn").click();
                    }, "DELETE", false, function (res) {
                        layer.msg(res.msg);
                    });
                }
            });
        };

        /**
         *
         * @param userIds
         * @constructor
         */
        let DeployDialog = function (userIds,language) {
            // alert(JSON.stringify(params))
            layer.open({
                content: '确定要发布吗?',
                yes: function (index, layero) {
                    layer.close(index); //如果设定了yes回调，需进行手工关闭
                    CoreUtil.sendAjax("/dEntry/updateEntryByAppr?releaseState=1&appr=0&language="+language, JSON.stringify(userIds), function (res) {
                        layer.msg(res.msg);
                        $(".layui-laypage-btn").click();
                    }, "DELETE", false, function (res) {
                        layer.msg(res.msg);
                    });
                }
            });
        };

        let cancleDeployDialog = function (userIds,language) {

            // alert(JSON.stringify(params))
            layer.open({
                content: '确定要取消发布吗?',
                yes: function (index, layero) {
                    layer.close(index); //如果设定了yes回调，需进行手工关闭
                    CoreUtil.sendAjax("/dEntry/updateEntryByAppr?releaseState=2&appr=0&language="+language, JSON.stringify(userIds), function (res) {
                        layer.msg(res.msg);
                        $(".layui-laypage-btn").click();
                    }, "DELETE", false, function (res) {
                        layer.msg(res.msg);
                    });
                }
            });
        };
        let shenheDeployDialog = function (userIds,language) {

            layer.open({
                content: '确定要通过审核吗?',
                yes: function (index, layero) {
                    layer.close(index); //如果设定了yes回调，需进行手工关闭
                    CoreUtil.sendAjax("/dEntry/updateEntryByAppr?releaseState=0&appr=2&language="+language, JSON.stringify(userIds), function (res) {
                        layer.msg(res.msg);
                        $(".layui-laypage-btn").click();
                    }, "DELETE", false, function (res) {
                        layer.msg(res.msg);
                    });
                }
            });
        };
        let cancleshenheDeployDialog = function (userIds,language) {

            layer.open({
                content: '确定要通过审核吗?',
                yes: function (index, layero) {
                    layer.close(index); //如果设定了yes回调，需进行手工关闭
                    CoreUtil.sendAjax("/dEntry/updateEntryByAppr?releaseState=0&appr=3&language="+language, JSON.stringify(userIds), function (res) {
                        layer.msg(res.msg);
                        $(".layui-laypage-btn").click();
                    }, "DELETE", false, function (res) {
                        layer.msg(res.msg);
                    });
                }
            });
        };

        //显示建议的详细信息
        let suggestiondetail = function(id){

            CoreUtil.sendAjax("/dLanguage/selectLanguageIsPage/" + id,null,function(res) {

                $("#username").html(res.data.username);
                $("#phone").html(res.data.phone);
                $("#email").html(res.data.email);
                $("#update_time").html(res.data.updateTime);
                $("#contents").html(res.data.content);

            }, "POST", false, function (res) {
                console.log(res);
                layer.msg(res.msg);
            });
            layer.open({
                //layer提供了5种层类型。可传入的值有：0（信息框，默认）1（页面层）2（iframe层）3（加载层）4（tips层）
                type: 1,
                resize: false, //是否允许拉伸
                maxmin: false, //最大最小化
                title: "建议详情",
                area: ['40%', '60%'],//宽，高
                shadeClose: true, //点击弹层外区域关闭
                content: $("#userInfoDetailDiv")
            });
        };


        //监听提交-编辑/新增用户信息弹框
        form.on('submit(edit-language-submit)', function (data) {
            // var level=   $("#level").value;
            // alert(level)
            //          if(!isNaN(level)){
            //              //对于空数组和只有一个数值成员的数组或全是数字组成的字符串，isNaN返回false，例如：'123'、[]、[2]、['123'],isNaN返回false,
            //              //所以如果不需要val包含这些特殊情况，则这个判断改写为if(!isNaN(val) && typeof val === 'number' )
            //
            //              return true;
            //          }
            //
            //          else{  layer.msg("等级只能是数字");
            //              return false;
            //          }

            if (data.field.id === undefined || data.field.id === null || data.field.id === "") {
                CoreUtil.sendAjax("/dEntry/addEntry", JSON.stringify(data.field), function (res) {
                    layer.closeAll(); //疯狂模式，关闭所有层
                    layer.msg(res.msg);
                    $(".layui-laypage-btn").click();
                }, "POST", false, function (res) {
                    layer.msg(res.msg);

                });
            } else {
alert("JSON.stringify(data.field)==============="+JSON.stringify(data.field))
                CoreUtil.sendAjax("/dEntry/updateEntry",JSON.stringify(data.field), function (res) {
                    layer.closeAll(); //疯狂模式，关闭所有层
                    layer.msg(res.msg);
                    $(".layui-laypage-btn").click();

                }, "PUT", false, function (res) {
                    layer.closeAll(); //疯狂模式，关闭所有层
                    layer.msg(res.msg);
                });
            }
            return false;

        });

        /**
         * 监听批量导入接口
         */
        form.on('submit(edit-batupload-submit)', function (data) {
            if (data.field.id === undefined || data.field.id === null || data.field.id === "") {
                CoreUtil.sendAjax("/dSubject/addSubject", JSON.stringify(data.field), function (res) {
                    layer.closeAll(); //疯狂模式，关闭所有层
                    layer.msg(res.msg);
                    $(".layui-laypage-btn").click();
                }, "POST", false, function (res) {
                    layer.msg(res.msg);
                });
            }
            return false;

        });
        //是否删除确认框
        let sureDelete = function (pkId,language) {
            layer.open({
                content: '确定要删除吗?',
                yes: function (index, layero) {
                    layer.close(index); //如果设定了yes回调，需进行手工关闭
                    CoreUtil.sendAjax("/dEntry/deleteEntry?language="+language, JSON.stringify(pkId), function (res) {
                        layer.msg(res.msg);
                        $(".layui-laypage-btn").click();
                    }, "DELETE", false, function (res) {
                        layer.msg(res.msg);
                    });
                }
            });
        };
    });
    layui.use('upload', function() {
        var $ = layui.jquery
            , upload = layui.upload;

        //多文件列表示例
        var demoListView = $('#demoList')
            , uploadListIns = upload.render({
            elem: '#testList'
            , url: '/fdfs/uploadFile ' //改成您自己的上传接口
            , accept: 'file'
            , multiple: true
            , auto: false
            ,data: {
                type: function(){
                    return $("#type").val();
                },
                statusv:function(){
                    return $("#statusva").val();
                }
            }
            , bindAction: '#testListAction'
            , choose: function (obj) {
                var files = this.files = obj.pushFile(); //将每次选择的文件追加到文件队列
                //读取本地文件
                obj.preview(function (index, file, result) {

                    var tr = $(['<tr id="upload-' + index + '">'
                        , '<td>' + file.name + '</td>'
                        , '<td>' + (file.size / 1024).toFixed(1) + 'kb</td>'
                        , '<td>等待上传</td>'
                        , '<td>'
                        , '<button class="layui-btn layui-btn-xs demo-reload layui-hide">重传</button>'
                        , '<button class="layui-btn layui-btn-xs layui-btn-danger demo-delete">删除</button>'
                        , '</td>'
                        , '</tr>'].join(''));

                    //单个重传
                    tr.find('.demo-reload').on('click', function () {

                        obj.upload(index, file);
                    });

                    //删除
                    tr.find('.demo-delete').on('click', function () {
                        delete files[index]; //删除对应的文件
                        tr.remove();
                        uploadListIns.config.elem.next()[0].value = ''; //清空 input file 值，以免删除后出现同名文件不可选
                    });

                    demoListView.append(tr);
                });
            }
            , done: function (res, index, upload) {
                if (res.data.fileName!="") { //上传成功
                    var tr = demoListView.find('tr#upload-' + index)
                        , tds = tr.children();
                    tds.eq(2).html('<span style="color: #5FB878;">上传成功</span>');
                    tds.eq(3).html(''); //清空操作
                    return delete this.files[index]; //删除文件队列已经上传成功的文件
                }
                this.error(index, upload);
            }
            , error: function (index, upload) {
                alert(2222)
                var tr = demoListView.find('tr#upload-' + index)
                    , tds = tr.children();
                tds.eq(2).html('<span style="color: #FF5722;">上传失败</span>');
                tds.eq(3).find('.demo-reload').removeClass('layui-hide'); //显示重传
            }
        });
    });
</script>